home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Power 1997 December
/
MACPOWER-1997-12.ISO.7z
/
MACPOWER-1997-12.ISO
/
AMUG
/
PROGRAMMING
/
Raven 1.2 Examples.sit
/
Raven 1.2 Examples
/
BoxPaint
/
Read Me
< prev
next >
Wrap
Text File
|
1997-04-12
|
3KB
|
87 lines
BoxPaint is a rewrite of an example in the QD 3D SDK called BoxPaint+. It
illustrates:
・ハHow Raven's QD 3D wrapper classes make it easier to use QD 3D.
・ハUsing QD 3D pick objects.
・ハTexture mapping.
Here's an example of how the wrapper classes compare with the procedural API.
First the Raven version:
void CDocument::CreateModel()
{
// Add the shaders
mModel.AddObject(T3DPhongShader());
mModel.AddObject(T3TextureShader(mTexture));
// Add the styles
mModel.AddObject(T3DInterpolationStyle(kQ3InterpolationStyleVertex));
mModel.AddObject(T3DSubdivisionStyle(kQ3SubdivisionMethodConstant, 16, 16));
// Our model is an ellipsoid.
T3DEllipsoid ellipsoid(kZero3DPt, T3DPoint(-1.0, 1.3, -1.0));
mModel.AddObject(ellipsoid);
// To get better performance we'll tell QD 3D not to save
// the state of our group when it needs to render it.
mModel.AddState(kQ3DisplayGroupStateMaskIsInline);
}
and now the SDK version:
TQ3GroupObject MyNewModel()
{
TQ3GroupObject myGroup = NULL;
TQ3GeometryObject myEllipsoid;
TQ3EllipsoidData myEllipsoidData;
TQ3ShaderObject myIlluminationShader;
TQ3StyleObject theStyleObject;
TQ3SubdivisionStyleData theSubdivisionStyleData;
if ((myGroup = Q3DisplayGroup_New()) != NULL ) {
/* Define a shading type for the group */
/* and add the shader to the group */
myIlluminationShader = Q3PhongIllumination_New();
Q3Group_AddObject(myGroup, myIlluminationShader);
theStyleObject = Q3InterpolationStyle_New(kQ3InterpolationStyleVertex);
Q3Group_AddObject(myGroup, theStyleObject);
Q3Object_Dispose(theStyleObject);
theSubdivisionStyleData.method = kQ3SubdivisionMethodConstant;
theSubdivisionStyleData.c1 = 16;
theSubdivisionStyleData.c2 = 16;
theStyleObject = Q3SubdivisionStyle_New(&theSubdivisionStyleData);
Q3Group_AddObject(myGroup, theStyleObject);
Q3Object_Dispose(theStyleObject);
myEllipsoidData.interiorAttributeSet = NULL;
myEllipsoidData.ellipsoidAttributeSet = NULL;
myEllipsoidData.caps = kQ3EndCapNone;
Q3Point3D_Set(&myEllipsoidData.origin, 0.0, 0.0, 0.0);
Q3Vector3D_Set(&myEllipsoidData.orientation, 0.0, 1.3, 0.0);
Q3Vector3D_Set(&myEllipsoidData.minorRadius, -1.0, 0.0, 0.0);
Q3Vector3D_Set(&myEllipsoidData.majorRadius, 0.0, 0.0, -1.0);
myEllipsoidData.uMin = 0.0; myEllipsoidData.uMax = 1.0;
myEllipsoidData.vMin = 0.0; myEllipsoidData.vMax = 1.0;
myEllipsoid = Q3Ellipsoid_New(&myEllipsoidData);
Q3Group_AddObject(myGroup, myEllipsoid);
}
}
Note that the Raven version is 10 lines of source compared to 33 lines for the
SDK version. Another major difference is that the Raven version uses exceptions
to handle errors. Because CreateModel uses stack based objects there won't be any
leaks if an exception is thrown. On the other hand, MyNewModel doesn't do any
error checking. If error checking was added it would be substantially larger.